package com.example.work4.http

import com.example.work4.common.FIN
import com.example.work4.data.MyObServerable
import com.example.work4.http.data.FriendList
import com.example.work4.http.imp.FriendRetrofit
import com.example.work4.po.ResultBean
import com.example.work4.po.SSOInfo
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class FriendRetrofitImp {
    private var retrofit = BaseRetrofit.get(FIN.BaseUrl)

    private var friendRetrofit = retrofit.create(FriendRetrofit::class.java)

    fun add(id : Int){
        SSOInfo.token?.let { friendRetrofit.add(it,id) }?.enqueue(object :
            Callback<ResultBean<Map<String, String>>> {
            override fun onResponse(call: Call<ResultBean<Map<String, String>>>,
                                    response: Response<ResultBean<Map<String, String>>>) {

            }

            override fun onFailure(call: Call<ResultBean<Map<String, String>>>, t: Throwable) {

            }
        })
    }


    fun addCall(id : Int): Call<ResultBean<Map<String, String>>> {
        return friendRetrofit.add(SSOInfo.token!!,id);
    }

    fun delCall(id : Int): Call<ResultBean<Map<String, String>>> {
        return friendRetrofit.del(SSOInfo.token!!,id);
    }


    fun listCall(): Call<ResultBean<FriendList>> {
            return friendRetrofit.getFriendsList(SSOInfo.token!!);
    }

}